import 'package:flutter/material.dart';
import '../model/details.dart'; //数据模型
import '../servie/service_method.dart';//接口请求
import 'dart:convert'; //json


class DetailsInfoProvide with ChangeNotifier {

  DetailsModel goodsinfo;
  bool isloading =  true;

   bool isLeft = true;
   bool isRight = false;

  //初始化页面
  changeInintstate(){
    isloading = true;
  }
  //改变tabBar的状态
  changeLeftAndRight(String changeState){
    if(changeState=='left'){
      isLeft=true;
      isRight=false;
    }else{
      isLeft=false;
      isRight=true;
    }
    notifyListeners();
  }
  //从后台获取商品数据
  getGoodsInfo(String goodsid) async{
    print('加载详情数据。。。');
    var fromData = {
      'goodId':goodsid
    };
    await requset('getGoodDetailById',formData: fromData).then((val){
      var responseData = json.decode(val.toString());
      goodsinfo = DetailsModel.fromJson(responseData);
      isloading = false;
      notifyListeners();
    });
  }
}
